#include <bits/stdc++.h>
using namespace std;
int main()
{
    freopen("file.in", "r", stdin);
    string ins;
    int k, n;
    cin >> ins >> k;
    n = ins.size();
    for (int i = k; i < n + k; i++)
        cout << ins[i % n] << endl;
    return 0;
}